
from DrissionPage._base.chromium import Chromium
from DrissionPage._configs.chromium_options import ChromiumOptions


co = ChromiumOptions()
# co = ChromiumOptions().headless()
# co.set_browser_path(r'/opt/google/chrome/google-chrome')
# co.set_argument('--no-sandbox')
# 设置启动时最大化
co.set_argument('--start-maximized')
# 无痕
# co.set_argument('--incognito')
# 连接浏览器
browser = Chromium(co)

tab = browser.latest_tab
tab.get(
        'https://jncc.jinan.gov.cn/jnfdcinfo/jnfdcweb/onsaling/show.shtml?prjno=38a28b95-e474-42c5-b657-5b65800c675b')
allcounts = tab.ele('#allcounts').value
allpage = tab.ele('#allpage').value
print(allcounts)
print(allpage)
title_list = tab.s_eles('.massage_bg')
for info in title_list:
    print(info.text)
    print(info.next().text)
# for page in range(int(allpage)):
#     tab.get(
#         f'https://jncc.jinan.gov.cn/jnfdcinfo/jnfdcweb/onsaling/show_{page + 1}.shtml?prjno=38a28b95-e474-42c5-b657-5b65800c675b')
#     links = tab.s_eles('#houseshow')
#     print(len(links))
#     for lnk in links:
#         if lnk.link.startswith('https'):
#             print(lnk.link)

        # browser.new_tab(lnk.link)